package org.ens.delegation.bo;

import javax.persistence.*;

/**
 * @author amine
 *
 */
@Entity
@Table(name="etablissement")
public class Etablissement implements IBusinessObject<String>{

	private String id;
	private String nomFr;
	private String nomAr;
	private TypeEtablissement typeEtablissement;
	private Commune commune;
	
	@Override
	@Id
	@Column(name="code_etab")
	public String getId() {
		return id;
	}

	@Override
	public void setId(String pk) {
		id = pk;
	}

	@Column(name="nom_etab_fr")
	public String getNomFr() {
		return nomFr;
	}

	public void setNomFr(String nomFr) {
		this.nomFr = nomFr;
	}

	@Column(name="nom_etab_ar")
	public String getNomAr() {
		return nomAr;
	}

	public void setNomAr(String nomAr) {
		this.nomAr = nomAr;
	}

	@ManyToOne
	@JoinColumn(name="type_etab")
	public TypeEtablissement getTypeEtablissement() {
		return typeEtablissement;
	}

	public void setTypeEtablissement(TypeEtablissement typeEtablissement) {
		this.typeEtablissement = typeEtablissement;
	}

	@ManyToOne
	@JoinColumn(name="commune")
	public Commune getCommune() {
		return commune;
	}

	public void setCommune(Commune commune) {
		this.commune = commune;
	}
	
	@Override
	public boolean equals(Object obj) {
		if(obj == null || !(obj instanceof Etablissement))
			return false;
		Etablissement etablissement = (Etablissement) obj;
		if(etablissement.getId() == null)
			return false;
	
		return etablissement.getId().equals(this.getId());
	}

}
